package com.cqjtu.drive.controller;

import com.cqjtu.drive.pojo.Coach;
import com.cqjtu.drive.pojo.Course;
import com.cqjtu.drive.response.Response;
import com.cqjtu.drive.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author zxl
 * @Date 2024/6/17 12:34
 */
@RestController
public class CourseController {
    @Autowired
    CourseService courseService;

    @PostMapping("/api/course/insert")
    public Response<String> insertCourse(@RequestBody Course course){
        return courseService.insertCourse(course);
    }

    @PostMapping("/api/course/update")
    public Response<String> updateCourse(@RequestBody Course course){
        return courseService.updateCourse(course);
    }

    @PostMapping("/api/course/delete")
    public Response<String> delete(@RequestParam String coId){
        return courseService.deleteCourse(coId);
    }

    @PostMapping("/api/course/getall")
    public Response<List<Course>> getall(){
        return courseService.getAllCourses();
    }

    @PostMapping("/api/course/getByname")
    public Response<List<Course>> getByname(@RequestParam String coName){
        return courseService.getCoursesByname(coName);
    }
    @PostMapping("/api/course/getBycId")
    public Response<List<Course>> getBycId(@RequestParam String cId){
        return courseService.getBycId(cId);
    }



}
